'use strict'

const Controller = require('egg').Controller

class AuthController extends Controller {
  async getAuthList() {
    const { ctx } = this
    const resBody = await ctx.service.managerrecord.auth.getAuthList(ctx.query)
    ctx.body = resBody
  }
  async getSingleAuth() {
    const { ctx } = this
    const resBody = await ctx.service.managerrecord.auth.getSingleAuth({
      id: ctx.params.id,
    })
    ctx.body = resBody
  }
  async createAuth() {
    const { ctx } = this
    const resBody = await ctx.service.managerrecord.auth.createAuth(
      ctx.request.body
    )
    ctx.body = resBody
  }
  async updateAuth() {
    const { ctx } = this
    const resBody = await ctx.service.managerrecord.auth.updateAuth(
      ctx.request.body,
      ctx.params.id
    )
    ctx.body = resBody
  }
  async deleteAuth() {
    const { ctx } = this
    const resBody = await ctx.service.managerrecord.auth.deleteAuth(
      ctx.params.id
    )
    ctx.body = resBody
  }
  // 通过角色获取列表
  async getAuthListByRoleName() {
    const { ctx } = this
    const resBody = await ctx.service.managerrecord.auth.getAuthListByRoleName({
      name: ctx.params.role,
    })
    ctx.body = resBody
  }
}

module.exports = AuthController
